﻿/*----------------------------------------------------------------
// Copyright (C) 2012 Q.FunnyFace
// 版权所有。 
//
// 文件名：ManagerCompany.cs
// 文件功能描述：企业信息业务逻辑
//
// 
// 创建标识：2012-10-29 zhangqiang
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using DomainModel;
using IDataAccess;
using IManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Manager
{

    /// <summary>
    /// 企业信息业务逻辑
    /// </summary>
    public class ManagerCompany : IManagerCompany
    {

        /// <summary>
        /// 企业信息数据访问接口
        /// </summary>
        public IDataAccessCompany IDACompany { get; set; }


        /// <summary>
        /// 更新企业信息
        /// </summary>
        /// <param name="companyInfo">企业信息</param>
        /// <returns>True=操作成功/False=操作失败</returns>
        public bool UpdateCompany(CompanyInfo companyInfo)
        {
            IDACompany.Update(companyInfo);
            IDACompany.UnitOfWork.Commit();
            return true;
        }


        /// <summary>
        /// 获取企业信息
        /// </summary>
        /// <param name="companyID">企业Id</param>
        /// <returns>企业信息</returns>
        public CompanyInfo GetCompany(int companyID)
        {
            return IDACompany.Find(companyID);
        }


        /// <summary>
        /// 获取企业信息
        /// </summary>
        /// <param name="where">条件</param>
        /// <returns>企业信息</returns>
        public CompanyInfo GetCompany(Expression<Func<CompanyInfo, bool>> where)
        {
            return IDACompany.Find(where);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public bool Contains(Expression<Func<CompanyInfo, bool>> where)
        {
            return IDACompany.Contains(where);
        }


        /// <summary>
        /// 添加企业信息
        /// </summary>
        /// <param name="companyInfo">企业信息</param>
        /// <returns>True=操作成功/False=操作失败</returns>
        public bool AddCompany(CompanyInfo companyInfo)
        {
            IDACompany.Create(companyInfo);
            IDACompany.UnitOfWork.Commit();
            return true;
        }
    }
}
